package embyparse.parsetree;

import emby.lang.EmbyNull;
import embyparse.noobparser.LiteralPattern;
import embyparse.noobparser.Pattern;

public abstract class LiteralNode extends ParseNode {

	public static ParseNode generateNull(int line){
		return new NullLiteral().setLine(line);
	}
	public static ParseNode generateInt(int i, int line){
		return new IntegerLiteral(i).setLine(line);
	}
	public static ParseNode generateDouble(double d, int line){
		return new DoubleLiteral(d).setLine(line);
	}
	public static ParseNode generateString(String s, int line){
		return new StringLiteral(s).setLine(line);
	}
	public static ParseNode generateBool(boolean b, int line){
		return new BooleanLiteral(b).setLine(line);
	}

	public LiteralNode(Pattern tag){
		super(tag,null,null);
	}

	public abstract Object getVal();
}

class NullLiteral extends LiteralNode{
	EmbyNull n = EmbyNull.Null;
	public NullLiteral(){
		super(LiteralPattern.nullLiteral);
	}
	public Object getVal(){
		return n;
	}
}
class IntegerLiteral extends LiteralNode{
	int i;
	public IntegerLiteral(int i){
		super(LiteralPattern.intLiteral);
		this.i=i;
	}
	public Object getVal(){
		return i;
	}
}
class DoubleLiteral extends LiteralNode{
	double d;
	public DoubleLiteral(double d){
		super(LiteralPattern.doubleLiteral);
		this.d=d;
	}
	public Object getVal(){
		return d;
	}
}
class StringLiteral extends LiteralNode{
	String s;
	public StringLiteral(String s){
		super(LiteralPattern.stringLiteral);
		this.s=s;
	}
	public Object getVal(){
		return s;
	}
}
class BooleanLiteral extends LiteralNode{
	boolean b;
	public BooleanLiteral(boolean b){
		super(LiteralPattern.booleanLiteral);
		this.b=b;
	}
	public Object getVal(){
		return b;
	}
}